<?php

/**
 * content actions.
 *
 * @package    semramode
 * @subpackage content
 * @author     Your name here
 * @version    SVN: $Id: actions.class.php 23810 2009-11-12 11:07:44Z Kris.Wallsmith $
 */
class contentActions extends sfActions
{
 /**
  * Executes index action
  *
  * @param sfRequest $request A request object
  */
  public function executeOverons(sfWebRequest $request)
  {
      $this->settings = Doctrine::getTable('Settings')->find(1);
    $breadcrumb = new breadcrumb();
$this->getUser()->setAttribute('breadcrumb', '');
$route[0]['title'] = $request->getParameter('title');
$route[0]['link'] = 'overons?title='.$request->getParameter('title');
$this->current = $route[0]['title'];
$this->breadcrumb = $breadcrumb->create($this->getUser(), $route);
$this->getUser()->setAttribute('breadcrumb', $this->breadcrumb);
      $this->content = Doctrine::getTable('content')->findOneBy('title', $request->getParameter('title'));
	$response = $this->getResponse();
	$this->content->setSeo($response);
  }

public function executeHome(sfWebRequest $request){
$this->settings = Doctrine::getTable('Settings')->find(1);
$this->content = Doctrine::getTable('content')->findOneBy('title', 'Home');

$this->images = $this->content->getHomeImages();
$response = $this->getResponse();
$this->content->setSeo($response);


}

public function executeCategory(sfWebRequest $request){
     $this->getUser()->setAttribute('breadcrumb', '');
  $this->categorys = Doctrine::getTable('category')->getAll();
$this->category = Doctrine::getTable('category')->findOneBy('name', $request->getParameter('title'));
$products = Doctrine::getTable('product')->showPublished($this->category->getId());
$this->getUser()->setAttribute('category', $this->category->getName());
$breadcrumb = new breadcrumb();
$route[0]['title'] = 'Collectie';
$route[0]['link'] = 'collectie';
$route[1]['title'] = $request->getParameter('title');
$route[1]['link'] = 'category?title='.$route[1]['title'];
$this->breadcrumb = $breadcrumb->create($this->getUser(), $route);
$this->getUser()->setAttribute('breadcrumb', $this->breadcrumb);
//pagination
$this->pager = new sfDoctrinePager('Products', 8);
$this->pager->setQuery(Doctrine::getTable('product')->showPublished($this->category->getId()));
$this->pager->setPage($request->getParameter('page', 1));
$this->pager->init();
//return $this->renderPartial('catresult', array('pager' => $this->pager, 'category' => $category,'breadcrumb' => $breadcrumb));
}
public function executeCollectie(sfWebRequest $request){
    $this->settings = Doctrine::getTable('Settings')->find(1);
    $this->categorys = Doctrine::getTable('category')->getAll();
     $this->getUser()->setAttribute('breadcrumb', '');
$breadcrumb = new breadcrumb();
$route[0]['title'] = 'Collectie';
$route[0]['link'] = 'collectie';
$this->breadcrumb = $breadcrumb->create($this->getUser(), $route);
$this->getUser()->setAttribute('breadcrumb', $this->breadcrumb);
}
public function executeFiltercategory(sfWebRequest $request){
  $category = $this->getUser()->getAttribute('category');
  $result = Doctrine::getTable('category')->findOneBy('name', $category);
  $products = $result->filterResult( $request->getParameter('brand'));
  //breadcrumbs
  $breadcrumb = new breadcrumb();
  $route[0]['title'] = $request->getParameter('brand');
  $this->breadcrumbs = $breadcrumb->addFilter($this->getUser(), $route);
  $this->getUser()->setAttribute('breadcrumb', $this->breadcrumb);
  //pagination
$this->pager = new sfDoctrinePager('Products', 8);
$this->pager->setQuery($products);
$this->pager->setPage($request->getParameter('page', 1));
$this->pager->init();
  return $this->renderPartial('result', array('pager' => $this->pager, 'breadcrumb' => $this->breadcrumbs));
}
public function executeContact(sfWebRequest $request){
    $this->settings = Doctrine::getTable('Settings')->find(1);
 $this->contacts = Doctrine::getTable('contact')->getContacts();
  $this->getUser()->setAttribute('breadcrumb', '');
 $this->forward404Unless($this->contacts);
}
public function executeAfspraak(sfWebRequest $request){
   $body = "Geachte Lezer, \n \r er is een afspraak aanvraag binnengekomen via semramode.nl: \n \r
       Naam:".$request->getParameter('naam')." \n \r Email:".$request->getParameter('email')."\n \r Product:".$request->getParameter('product')." \n \r Bericht:".$request->getParameter('bericht');
   $subject =' Afspraak aanvraag semramode.nl: '.$request->getParameter('onderwerp');
   $this->getMailer()->composeAndSend('info@semramode.nl', 'mydropz@gmail.com', $subject, $body);
 
   return sfView::success;
}
public function executeCollect(){
    $collect = new collector();
    $collect->collect();

}
}